package pl.edu.agh.sr.lab3.zad2.impl.common;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class Config {
	// String IOR_REFERENCE =
	// "IOR:010000002b00000049444c3a6f6d672e6f72672f436f734e616d696e672f4e616d696e67436f6e746578744578743a312e300000010000000000000074000000010102000f0000003134392e3135362e39372e3135350000c05a00000b0000004e616d6553657276696365000300000000000000080000000100000000545441010000001c000000010000000100010001000000010001050901010001000000090101000354544108000000af428b4f0100022c";
	// String AFACTORY_NAME = "srTDzServer";

	private static Properties properties;

	
	public static String getAFactoryName(){
		if (properties == null) {
			initProperties();
		}
		String factoryName = properties.getProperty("factoryName");
		System.out.println("[config] factoryName: " + factoryName);
		return factoryName;
	}
	
	public static String getIOR_Reference() {
		if (properties == null) {
			initProperties();
		}
		String ior = properties.getProperty("ior");
		System.out.println("[config] ior: " + ior);
		return ior;
	}

	private static void initProperties() {
		properties = new Properties();
		try {
			properties.load(new FileInputStream("corba.properties"));
		} catch (IOException e) {
			System.err.println("[config] error initializing properties");
			e.printStackTrace();
		}
		System.err.println("[config] initialized");

	}

}
